import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.leadingsoft.pwxk.DataFetchApplication;
import com.leadingsoft.pwxk.commons.DealDataResult;
import com.leadingsoft.pwxk.enums.InterfaceEnum;
import com.leadingsoft.pwxk.model.AuditAirPollutionEmissions;
import com.leadingsoft.pwxk.model.BaseInfo;
import com.leadingsoft.pwxk.model.PwBaseInfo;
import com.leadingsoft.pwxk.services.AbstractService;
import com.leadingsoft.pwxk.services.BaseInfoService;
import com.leadingsoft.pwxk.services.impl.PwBaseInfoServiceImpl;
import com.leadingsoft.pwxk.utils.AesUtilTest;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

import java.io.UnsupportedEncodingException;
import java.util.List;

/**
 * @ClassName test
 * @Description test
 * @Author SunFeng
 * @Date 2020/3/2 17:51
 * @Version 1.0
 */
@RunWith(SpringRunner.class)
@SpringBootTest(classes = DataFetchApplication.class)
public class test {

    @Autowired
    private PwBaseInfoServiceImpl pwBaseInfoService;

    @Test
    public void test1() throws UnsupportedEncodingException {
        String result = "E7C906A12EC21BE85820DD249F4652FA89FAF7A9AEB0CD2007FBE4D751925363A3FE9DA803A924A33863AAA96AB254E979854473576BFDB281A7A72D080E0FF02FC05525498183B2C794044249AC7E09B5447C9A461929BA529B46CD254CBC900F60C5586017644CA37EE6AA6B7BA4AC0016A80417F28B80CD135B1ECE2DC70C99285DC91A6773ECD2C263846C74F17C220F691E62C0CF41B8050C3A332C6560F05207EF99246B1E9B1503673C865296702277D95F78D0A4E739075510875AA8A86B69E49755224D84FAD266F38E94F825FAE88FAFBAB907817B65F7EF115CFB73AFF87C437CDE533F0918181FC7BB49EDECB40FF533760BA7305A6211F58B35A74755D99E7B884EDDC08F9D3905D0DD90E8867396E774C95719160FBBC7D48F5E9EB98D6DF94CA9CA1FF32FD33366185FAE1B12C894A9F9666D0BF157E38F45B5BEFEEFCF99D77BFB3BF145A3953ABFFBB48F8B5C02EE6D95AE6CE0DD3DB61B14AE03171DAFC36E50E90A548D26244E54A1A1B2DD0D64D620EF37A62315DE4695E5380EC9584CBE21A0184E4288E2799A1ED1651B89B186BDD9B0DCC4C825DC32D428BCB1642F773B5DB6E7E7B8DD1762909670E3EC20982AB1E2B8E4A6418D324B500E8DABD728491312C719156B63CA53807177AD567D4892FE7713C06A1CB2CE8E631A46698F8CC78FF0F8ED62D7910D09474A10E77DE669E82B85613B1B203595C2D0EEF52AD336EF60DEA464D272D8806254169C59F7FBC245638DA555D017F566DDB13AE89160B51E18E1CE4BB2CE8E631A46698F8CC78FF0F8ED62D7910D09474A10E77DE669E82B85613B1B56330B253ECEDCEC07DE06CC4579A3F5FCA539079597350E8C82B532852E10B4BB6085B8BB59646884B1715A50D0789DBA3879C780966A83FC6230DA671835E978CC3147AA9D99CAA7029AEE87552F8C83337A288545EB5145D5B5414CF20680349A399377A813AB6468CF3FA26A56B04E5540D3DD151A4C38FA22D06DD24AAB13C23FACF82F2A1037EBBE689EC0906569BF8201C36C5D9F264FD329FBF8B420A3BEFBE441B83C518790C720AB1104C0D083B54128575857BFE6F6F90C19C6685D3B3DD6627A232A4436A76488800904ED49059EDB94D4B6CA97CB2743E68E9033A79FAFE19A86684773651E50664FA9CAD168ED49216FA388E8C1498BFBF79F7C48B15CDB43AAF26DCEF0E2F10629CA77FB1FFD1E7361F69D347E7A3169BD8233AEA34327DF6D8587C34BEB3B6C0920AF245EAE9910EFD1C82B06F677BB719E8D116ABDC91DC11C362D4583C67EB63312A477476F8BAE9496238A7141ED7DCED763571C89A3EFBEFD51CA79124AFCF56BA8D9FDFFB369DFB21AA47BC6BBA24D08ACA7FDB33341207C4F0DB535FE3C79645B3A4F6756B85815B4253E450BD0CB5F34007C69340DE38C4D07D2DAD41A5B9C264D3251E1F4AB95685F72072C1D941623434F65DBDE05F5FCFE11C58A51E20687096AFFBF063E16E4766316DF7AAB8F5FA424802649E1B8380A833CD67CAE";


        AesUtilTest test = new AesUtilTest();

        byte[] aesResult = test.decrypt(test.parseHexStr2Byte(result), "d78ac60348db40a3bd61d0f452cec9d7");
      System.out.println("解密后为：" + new String(aesResult, "utf-8"));
        String datas = new String(aesResult, "utf-8");
        JSONArray jsonArray = JSONArray.parseArray(datas);
        JSONObject jsonRoot = jsonArray.getJSONObject(0);
        String result1 =
                jsonRoot.get("result").toString();
        PwBaseInfo pwBaseInfo = JSONObject.parseObject(result1, PwBaseInfo.class);
        System.out.println(pwBaseInfo);

//        List<PwBaseInfo> pwBaseInfos = JSONArray.parseArray(datas, PwBaseInfo.class);
//        System.out.println(pwBaseInfos);
        pwBaseInfoService.save(pwBaseInfo);
    }


}
